import router from "@/routes/router";
import {getUserStorage} from "@/utils/setStorage";
import {dynamic_routes} from '@/routes/router'
import {useUserStore} from "@/stores";

export const initRoute = () => {
  console.log('----路由初始化----')
  const userInfo = getUserStorage();
  if (userInfo) {
    const allow_routes = dynamic_routes.filter(v => {
      return userInfo.permission_list.includes(v.name)
    })
    allow_routes.forEach(v => {
      router.addRoute('main', v)
    })
    useUserStore().setUser(userInfo)
    console.log('-----', router.getRoutes())
  }
}